<!DOCTYPE html>
<html>
<head>
	<meta charset="utf-8">
	<title>产品</title>
	<meta name="renderer" content="webkit">
	<meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
	<meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1">
	<meta name="apple-mobile-web-app-status-bar-style" content="black">
	<meta name="apple-mobile-web-app-capable" content="yes">
	<meta name="format-detection" content="telephone=no">
	<style>
		html{ padding: 10px}
	</style>
</head>
<body class="childrenBody">
<blockquote class="layui-elem-quote">产品编辑</blockquote>
<form class="layui-form" id="bd1">


	<div class="layui-form-item">
		<label class="layui-form-label">产品名称</label>
		<div class="layui-input-block">
			<input type="text" class="layui-input newsName" id="newsName"  value="{$t.name}" name="name" placeholder="请输入产品名称">
		</div>
	</div>



	<div class="layui-form-item">
		<div class="layui-inline">
			<label class="layui-form-label">价格</label>
			<div class="layui-input-inline">
				<input type="text" id="newsPrice" name="price" value="{$t.price}" class="layui-input newsAuthor" placeholder="请输入价格" onkeyup="if(isNaN(value))execCommand('undo')" onafterpaste="if(isNaN(value))execCommand('undo')">
			</div>
		</div>
    </div>    
 	<div class="layui-form-item">
	 	<label class="layui-form-label">选择分类</label>
		<div class="layui-input-inline">
			<select class="newsLook" id="newsCate" name="cate" lay-filter="browseLook">
               	{empty name="t.cate"}
					<option value="0"></option>
				{else /}
					<option>{$t.cate}</option>
               	{/empty}
				
				{volist name="catelist" id="v"}
					<option>{$v.name}</option>
				{/volist}
			</select>
		</div>

       	{empty name="t.bid"}

	 	<label class="layui-form-label">选择商家</label>
	 	<div class="layui-input-inline">
			<select class="newsLook" id="newsShop" name="bid" lay-filter="browseLook">

				<option value="0"></option>

				
				{volist name="sj" id="v"}
				<option value="{$v.id}">{$v.qymc}</option>
				{/volist}
			</select>
		</div>
		
      	{/empty}


	</div>

    

	<div class="layui-form-item">
		<label class="layui-form-label">运费说明</label>
		<div class="layui-input-block">
			<input type="text" class="layui-input newsName" lay-verify="title" value="{$t.yfdesc}" name="yfdesc" placeholder="请说明不包邮地区">
		</div>
	</div>

 <div class="layui-form-item">
		<label class="layui-form-label">产品网址</label>
		<div class="layui-input-block">
			<input type="text" class="layui-input newsName" lay-verify="title" value="{$t.url}" name="url" placeholder="如果添加网址，该产品将跳转到第三方平台">
		</div>
	</div>


	<div class="layui-form-item">
		<label class="layui-form-label">缩略图400*400</label>
		<div class="layui-input-block">

			
			<img src="{$t.pic|default='http://img.77wx.cn/nopic.jpg'}" width="200" height="200" id="pic" />
			<img src="{$t.pic1|default='http://img.77wx.cn/nopic.jpg'}" width="200" height="200" id="pic1" />
			<img src="{$t.pic2|default='http://img.77wx.cn/nopic.jpg'}" width="200" height="200" id="pic2" />
			<img src="{$t.pic3|default='http://img.77wx.cn/nopic.jpg'}" width="200" height="200" id="pic3" />
			<img src="{$t.pic4|default='http://img.77wx.cn/nopic.jpg'}" width="200" height="200" id="pic4" />

		</div>

		<input name="pic" type="hidden" id="picval" value="{$t.pic}" />
		<input name="pic1" type="hidden" id="picval1" value="{$t.pic1}" />
		<input name="pic2" type="hidden" id="picval2" value="{$t.pic2}" />
		<input name="pic3" type="hidden" id="picval3" value="{$t.pic3}" />
		<input name="pic4" type="hidden" id="picval4" value="{$t.pic4}" />

		<input name="tid" type="hidden" value="{$t.id}">
	</div>


	<div class="layui-form-item">
		<label class="layui-form-label">产品详情</label>
		<div class="layui-input-block">
				<textarea name="content" id="news_content" style="height: 600px">


					{$t.content}
				</textarea>
		</div>
	</div>
	
	
	<div class="layui-form-item">
		<div class="layui-input-block">
			<button class="layui-btn" type="button"  lay-submit="" lay-filter="addNews" >立即提交</button>
			<button type="reset" class="layui-btn layui-btn-primary">重置</button>
		</div>
	</div>
</form>
{:jq()}
{:layui()}
{:ue()}
<script type="text/javascript">



    layui.upload.render({
        elem: '#pic'
        ,url: "{:url('api/upload/qiniu')}"
        ,size: 500000 //限制文件大小，单位 KB
        ,done: function(res){
        	if(res.code==200){
        		layer.msg('上传成功');
               $("#picval").val(res.url);
             $("#pic").attr('src',res.url);

        	}
           
        }
    });

     layui.upload.render({
        elem: '#pic1'
        ,url: "{:url('api/upload/qiniu')}"
        ,size: 500000 //限制文件大小，单位 KB
        ,done: function(res){
        	if(res.code==200){
        		layer.msg('上传成功');
               $("#picval1").val(res.url);
             $("#pic1").attr('src',res.url);

        	}
           
        }
    });

      layui.upload.render({
        elem: '#pic2'
        ,url: "{:url('api/upload/qiniu')}"
        ,size: 500000 //限制文件大小，单位 KB
        ,done: function(res){
        	if(res.code==200){
        		layer.msg('上传成功');
               $("#picval2").val(res.url);
             $("#pic2").attr('src',res.url);

        	}
           
        }
    });

       layui.upload.render({
        elem: '#pic3'
        ,url: "{:url('api/upload/qiniu')}"
        ,size: 500000 //限制文件大小，单位 KB
        ,done: function(res){
        	if(res.code==200){
        		layer.msg('上传成功');
               $("#picval3").val(res.url);
             $("#pic3").attr('src',res.url);

        	}
           
        }
    });

        layui.upload.render({
        elem: '#pic4'
        ,url: "{:url('api/upload/qiniu')}"
        ,size: 500000 //限制文件大小，单位 KB
        ,done: function(res){
        	if(res.code==200){
        		layer.msg('上传成功');
               $("#picval4").val(res.url);
             $("#pic4").attr('src',res.url);

        	}
           
        }
    });





    var ue = UE.getEditor('news_content',{

        height:700
    });
    
    $(function(){
    	layui.form.on('submit(addNews)', function(data){
          	var newsName = $("#newsName").val();
          	var newsPrice = $("#newsPrice").val();
          	var newsCate = $("#newsCate").val();
          	var newsShop = $("#newsShop").val();
          	var news_content = $("#news_content").text();
          	if (newsName == '') {
	          	alert('产品名称不能为空');
          	} else if (newsPrice == '') {
	          	alert('产品价格不能为空');
          	} else if (newsCate == 0) {
	          	alert('产品分类不能为空');
          	} else if (newsShop == 0) {
	          	alert('产品商家不能为空');
          	} else if (news_content == '') {
	          	alert('产品详情不能为空');
          	} else {
          		$.post(' ',data.field,function(res){

	                if(res.code==200){

	                layer.alert('发布成功，点确定继续上传',function(){

	                     
	                     window.location.reload();

	                });

	                }


	          	});
          	}

	    });
    })
</script>
</body>
</html>